<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.smartview.jboss.spring.dto.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Weather Information</title>
<style type="text/css">
   body{ 
		background:#d8e6ec url(/smartView/pic/bg_body.gif) repeat-x;
        font:80% Arial, Helvetica, Sans-Serif;
		color:#555;
		line-height:180%;
		margin:0;
		padding:0;
		text-align:center;
        }
	h1{
		font-size:60pt;
		font-weight:normal;
		margin:0;
		padding-left:35px;
		padding-top:100px;
		color: white;
		
		}	
	h2, h3, h4, h5, h6{
		font-weight:normal;
		margin:1em 0;
		}	
	h2{            
		font-size:160%;
		}	
	h3{          
		font-size:140%;
		}
	h4{          
		font-size:120%;
		}				
	a{
		text-shadow: #a7a7a7 0 -1px 15px;
		color:#100;
		font-variant:small-caps;
		-webkit-transition:0.3s linear;
		}
	a:hover{
		color:#3f3f3f;
		background-color: #778caa;
		text-shadow:#bebebe 0 1px 0;
		}							
	p{
		margin:1em 0;
		}		


th {
	font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica,
	sans-serif;
	color: #6D929B;
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	border-top: 1px solid #C1DAD7;
	letter-spacing: 2px;
	text-transform: uppercase;
	text-align: left;
	padding: 6px 6px 6px 12px;
	background: #CAE8EA url(/smartView/pic/bg_header1.jpg) no-repeat;
}

th.nobg {
	border-top: 0;
	border-left: 0;
	border-right: 1px solid #C1DAD7;
	background: none;
}

th.spec {	
	border-left: 1px solid #C1DAD7;
	border-top: 0;
	background: #fff url(/smartView/pic/bullet1.gif) no-repeat;
	font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica,
	sans-serif;
}

th.specalt {
	border-left: 1px solid #C1DAD7;
	border-top: 0;
	background: #f5fafa url(/smartView/pic/bullet2.gif) no-repeat;
	font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica,
	sans-serif;
	color: #B4AA9D;
}


td {
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	background: #fff;
	padding: 6px 6px 6px 12px;
	color: #6D929B;
}


td.alt {
	background: #F5FAFA;
	color: #B4AA9D;
}

	#container{	
		margin:0 auto;
		width:928px;
		text-align:left;
		}
	#header{
		height:236px;
		background:url(/smartView/pic/bg_header.jpg) no-repeat 0 0;
		}				
	#content{
		background:url(/smartView/pic/bg_content.gif) repeat-y;
		padding:.5em 34px;
		}
	#footer{
		padding:25px 60px;
		background:url(/smartView/pic/bg_footer.gif) no-repeat 0 0;				
		color:#fff;
		}				


</style>
<script language="JavaScript">
<!--

function deletePopup(service_code)
{
	var form = document.f;
	
	form.method = "post";
	form.action="/smartView/spring/deleteService";
	document.getElementById("service_code").value = service_code;
	form.submit();
}

function addService(service_code, service_id, service_pw){
	var form = document.f;
	
	if(service_code=='0')
		service_id = document.getElementById("yahooWeather").value;
	if(service_code=='4')
		service_id = document.getElementById("yahooCompany").value;
	
 	form.method = "post";
	form.action="/smartView/spring/addService";
	document.getElementById("service_code").value = service_code;
	document.getElementById("service_pw").value = service_pw;
	document.getElementById("service_id").value = service_id;
	form.submit(); 
}

//-->
</script>
</head>

<body>
	<form name="f">
		<input type="hidden" name="service_code" id="service_code" />
		<input type="hidden" name="service_pw" id="service_pw" />
		<input type="hidden" name="service_id" id="service_id" />
<div id="container">	
	<p>Welcome ${id} !</p>
	<p>
		<a href="<spring:url value="/"/>">Home</a><br>
		<a href="/smartView/j_spring_security_logout">Logout</a>
		
	</p>

	<c:choose>
		<c:when test="${use0 == 1}">
	Today's Weather !
	<a href="javascript:deletePopup('0')">delete</a>
			<table border="1">
				<th>zip</th>
				<th>city</th>
				<th>state</th>
				<th>country</th>
				<th>logitude</th>
				<th>latitude</th>
				<th>temperature</th>
				<tr>
					<td><c:out value="${weather.zip}" /></td>
					<td><c:out value="${weather.city}" /></td>
					<td><c:out value="${weather.state}" /></td>
					<td><c:out value="${weather.country}" /></td>
					<td><c:out value="${weather.longitude}" /></td>
					<td><c:out value="${weather.latitude}" /></td>
					<td><c:out value="${weather.temperature}" /></td>
				</tr>
			</table>
			<br>
			<br>
			<br>
		</c:when>
		<c:otherwise>
			Zip code : <input type="text" id="yahooWeather"> <a href="javascript:addService('0','0', '0')"> add Yahoo Weather</a>
 		</c:otherwise>
	</c:choose>
	
	<br>
	<br>
	<br>

	<c:choose>
		<c:when test="${use3 == 1}">
			<img src="http://l.yimg.com/a/i/us/nws/th/main_142c.gif"
				alt="Yahoo News" />   		       
		Yahoo! News - Latest News & Headlines
		<a href="javascript:deletePopup('3')">delete</a>
			<table border="1">
				<th width="30" height="5">published date</th>
<!-- 				<th width="120" height="5">img</th> -->
				<th width="600" height="5">title</th>
				<th width="30" height="5">source</th>
<!-- 				<th width="185" height="5">description</th> -->

				<c:forEach var="i" items="${newsList}">

					<tr>
						<td width="30" height="20">
							<p>${i.pubDate}</p>
						</td>
<%-- 						<td width="120" height="40">
							<p>${i.img}</p>
						</td> --%>
						<td width="600" height="20">
							<p>
								<a href="${i.link}">${i.title}</a>
							</p>
						</td>
						<td width="30" height="20">
							<p>${i.source}</p>
						</td>
<%-- 						<td width="185" height="20">
							<p>${i.description}</p>
						</td> --%>

					</tr>
				</c:forEach>
			</table>
		</c:when>
		<c:otherwise>
			<a href="javascript:addService('3','0','0')">add Yahoo News</a>
 		</c:otherwise>
	</c:choose>

	<br>
	<br>
	<br>

	<c:choose>

		<c:when test="${use4 == 1}">
			<img src="http://l.yimg.com/a/i/brand/purplelogo/uh/us/fin.gif"
				alt="Yahoo Company News" />   		       
		Yahoo! News - Company financial News
		<a href="javascript:deletePopup('4')">delete</a>
			<table border="1">
				<th width="250" height="5">published date</th>
				<th width="800" height="5">content</th>

				<c:forEach var="i" items="${companyList}">
					<tr>
						<td width="50" height="5">
							<p>${i.pubDate}</p>
						</td>
						<td width="600" height="5">
							<p>
								<a href="${i.link}">${i.title}</a>
							</p>
						</td>

					</tr>
				</c:forEach>
			</table>
		</c:when>
		<c:otherwise>
				service : 
					<select name="yahooCompany" id="yahooCompany">
							<option value="yhoo">Yahoo</option>
							<option value="msft">Microsoft</option>
							<option value="tivo">Tivo</option>
							<option value="yhoo,msft,tivo">All</option>
					</select>
			<a href="javascript:addService('4','0')">add Yahoo Company(financial) News</a>
 		</c:otherwise>
	</c:choose>
	</form>
	</div>
</body>
</html>
